# recode and center dates around the taliban takeover
ESS10 <- tidyr::separate(ESS10, inwds, c("date", "time"), sep = " ")
ESS10$date <- as.Date(ESS10$date)
ESS10$date <- as.numeric(ESS10$date)
ESS10$date <- ESS10$date - 18854 # 15 Aug 2021 is 0 now (Taliban Takeover) 


### recode variables of interest ###

# imwbcnt -> high values = "Immigrants make country better"
ESS10$mig <- as.numeric(ESS10$imwbcnt) 

# imueclt -> high values = "Cultural life enriched by migrants"
ESS10$cul <- as.numeric(ESS10$imueclt)

# imbgeco -> high values = "Immigration good for economy"
ESS10$eco <- as.numeric(ESS10$imbgeco)

# lrscale 0 = left, 10 = right
ESS10$lrscale <- as.numeric(ESS10$lrscale)

# create treatment variable
ESS10 <- ESS10 %>% 
  mutate(afg = ifelse(date > -1,1,0)) # Treatment is 1 after 15 Aug 2021
